import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Opengauss_Function_SlowSQL_Record_Case0031{
    private static Connection openGaussConnection;

    public static void main(String[] args) {
        if (args.length < 4) {
            System.out.print("need para: host:ip,dbname,username,password");
            return;
        }
        String url = "jdbc:postgresql://" + args[0] + "/" + args[1] + "?LoggerLevel=TRACE";
        try {
            openGaussConnection = DriverManager.getConnection(url, args[2], args[3]);
            testRecordSlowSQL();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }

    public static void testRecordSlowSQL() throws SQLException {
        Statement statement = openGaussConnection.createStatement();
        String sql = "select t1.id from query_plan_table t1 where t1.id=1;\n" +
                "select count(t1.num) from query_plan_table t1,query_plan_table t2;";
        statement.execute(sql);
    }
}